/********************************************************************
	TABAL ENGINE - 2012/10/28
	author:		Marc Cuscullola
	
	purpose:	Basic math functions
*********************************************************************/
#pragma once

#ifndef __MATH_UTILS__INCLUDED_H__
#define __MATH_UTILS__INCLUDED_H__

#include <math.h>
#include "MathTypes.h"
#include "MathUtils.inl"

namespace Math
{
namespace Utils
{
	template <typename T>	inline T		Pow2    (T _val);
	template <typename T>	inline T		PowN    (T _val,int _n);

	template <typename T>	inline T		Log     (T val);
	template <typename T>	inline T	 	LogBase	(T val, T base);

	template <typename T>	inline T		Min     (T _a, T _b);
	template <typename T>	inline T		Max     (T _a, T _b);
	template <typename T>	inline T		Clamp   (T _val, T _min, T _max);

	template <typename T>	inline T		Abs     (T _val);
	template <typename T>	inline T		Floor   (T _val);
	template <typename T>	inline T		Ceil    (T _val);
	template <typename T>	inline T		Round   (T _val);
	template <typename T>	inline T		Exp     (T _val);
	template <typename T>	inline void		Swap    (T& _a, T& _b);

	template <typename T>	inline T		Lerp    (const T& _a, const T& _b, const T& _lambda);

	template <class T>      inline bool		InRangeNonSorted_Open	(T const& _val, T const& _ref0, T const& _ref1);
	template <class T>      inline bool		InRangeNonSorted_Close	(T const& _val, T const& _ref0, T const& _ref1);
	template <class T>      inline bool		IsPair					(T const& _val);
	template <typename T>	inline bool		IsPositive				(T _fVal);

	inline float	Sign		(float _fVal);

	inline uint32	RoundUp4	(uint32 _n);
	inline uint32	RoundUp32	(uint32 _n);
	inline uint32	RoundDown32	(uint32 _n);
	inline bool		IsPowerOf2	(uint32 _n);


} //namespace Utils
} //namespace Math

#endif //__MATH_UTILS__INCLUDED_H__
